<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>添加快捷回复</title>
<link rel="stylesheet" type="text/css" href="layui/css/layui.css" media="all">
<script type="text/javascript" src="js/base64/base64.js"></script>
<script type="text/javascript" src="layui/layui.js"></script>
<script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">

function ajax(msg) {
	var event = document.createEvent('MessageEvent');
	var origin = window.location.protocol + '//' + window.location.host;
	event.initMessageEvent('MessageReceived', true, true, msg, origin, 1234, window, null);
	document.dispatchEvent(event);
}
// 全局接收消息事件
function messageReceived(res) {

}

</script>
<style type="text/css">
body{ padding: 10px; }
</style>
</head>
<body>
<form class="layui-form"  onsubmit="return check()" > <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
<div class="layui-form-item">
    <label class="layui-form-label">类型</label>
    <div class="layui-input-block">
      <input type="radio" name="types" value="0" title="文字" checked>
      <input type="radio" name="types" value="1" title="图文">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">排序</label>
    <div class="layui-input-block">
      <input type="text" name="indexs" id="indexs" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" placeholder="请输入排序" autocomplete="off" class="layui-input">
    </div>
  </div>
   <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">内容</label>
    <div class="layui-input-block">
      <textarea name="content" id="content" placeholder="请输入内容" class="layui-textarea"></textarea>
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" id="Btn" type="button" >立即提交</button>
    </div>
  </div>
</form>

  
</body>
<script type="text/javascript">
		/*获取选中的id值*/
		$("#Btn").click(function(){
			var types = $('input:radio[name="types"]:checked').val();
			var indexs = $("#indexs").val();
			var content = $("#content").val();
			var data_opt = {
				type: "QuickReply/Add",
				data: {
					types : types,
					indexs : indexs,
					content : content,
				}
			}
			data_opt = JSON.stringify(data_opt);
			ajax(data_opt);
		});
</script>
<script>
layui.use('form', function(){
  var form = layui.form;
  //各种基于事件的操作，下面会有进一步介绍
  
});
</script>
</html>
